<template>
  <div class="detail">
    <p>计数器：{{ count }}</p>
  </div>
</template>
<script>
import { ref, watch } from "vue";
export default {
  setup () {
    const count = ref(0);
    // 1. 监听一个响应式数据
    // watch(数据, 改变后回调函数)
    watch(count, () => {
      console.log("count改变了");
    });
    // 2s改变数据
    setTimeout(() => {
      count.value++;
    }, 1000);

    // 组件生命周期
    onMounted(() => {
      console.log("onMoutend组件生命周期触发了");
    })
    return { count };


  },
};
</script>